import Ajax from "@/utils/request";
const basePath = import.meta.env.VITE_BASE_URL
export const apiUser ={
    // getUserInfo: (): Promise<any>=>{
    //     return Ajax.request(
    //         '/profile/myInfo',
    //         {},
    //         'json',
    //         'get',
    //         true,
    //     );
    // },
    //todo: 获取用户信息，暂时只从mock获取
    getUserInfo: (): Promise<any>=>{
        return Ajax.request(
            '/user/getInfo',
            {},
            'json',
            'POST',
        );
    },
    login: (params:any): Promise<any>=>{
        return Ajax.request(
            '/user/login',
            params,
            'json',
        );
    },
    logout: (): Promise<any>=>{
        return Ajax.request(
            '/noop/logout',
            {},
            'json',
            'get'
        );
    },
    noop:  (): Promise<any>=>{
        return Ajax.request(
            '/noop',
            {},
            'json',
            'get'
        );
    },
    //单点登录step1:获取auth_code
    getAuthCode: (clientId:string): Promise<any>=>{
        return Ajax.request(
            basePath+'/sso/sso/login/authcode?clientId='+clientId,
            {},
            'json',
            'get'
        );
    },
    //单点登录step2:用auth_code生成access_token
    accessToken:  (code:string): Promise<any>=>{
        return Ajax.request(
            '/oauth/access-token?code='+code,
            {},
            'json',
            'get'
        );
    },
}